<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt"%>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title><spring:message  code="pim"/> - <spring:message  code="manage.news"/></title>
<link href="<%= request.getContextPath() %>/css/custom.css" rel="stylesheet" type="text/css" />
<link href="<%= request.getContextPath() %>/css/style.css" rel="stylesheet" type="text/css" />
<link href="<%= request.getContextPath() %>/css/v.css" rel="stylesheet" type="text/css" />
<link href="<%= request.getContextPath() %>/css/paging.css" rel="stylesheet" type="text/css" />
<link href="<%= request.getContextPath() %>/css/jquery.ui.dialog.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery-1.6.2.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery-ui-1.8.14.custom.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery.hint.text.js"></script>
<%@include file="script/pim-util.jsp" %>
<%@include file="script/paging-script.jsp" %>
<%@include file="script/news-script.jsp" %>
<script type="text/javascript">
jQuery(document).ready(function(){    
    $('input[title]').inputHints();	
});   
</script>
</head>
<body>
<% try{ %>
<c:if test="${bean.isSigned}">
<div id="all">
<div id="wrapper">
<div id="mainheader">
	<jsp:include page="include/common/headerSignedIn.jsp" />
</div> 
<div id="content-wrapper">
<div id="top-menu">
	<jsp:include page="include/common/topMenuHome.jsp" />
</div>
<div class="pg-left-panel">
	<jsp:include page="include/common/leftMenu.jsp" />
</div>
<div class="right-panel-application">
<div id="dialogDeleteNews"></div>
<form:form action="" method="post" commandName="newsQuery" name="frmNews">
	<div style="margin-top:12px;">	     
	     <div class="v-row">	    
		   <div class="v-row-right"> 	
	        <form:input maxlength="50" cssClass="new-manage-org-search txt-search"  path="searchKey" 
	           cssStyle="margin-right: 10px;" title="Keyword..."/>
	        <input type="button" class="bt-form" id="searchNews" style="margin-right: 10px;"
				   value='<spring:message  code="search"/>'>
			</div>	   
	     </div>
									
		<div><b style="margin-left: 10px;" 
		     class="v-title"><spring:message  code="listOfNews"/></b>
		</div>	
		
		<div class="new-manage-org-dot-line"></div>		
		<c:choose>
		<c:when test="${bean.countList == 0 && newsQuery.searchKey != ''}">
			<div class="new-manage-org-list-content" style="margin-right: 18px;">
				<span style="margin-left: 10px;"><spring:message  code="search.empty"/></span>
			</div>
		</c:when>		
		<c:otherwise>
		<c:if test="${bean.isAdmin}">
			<div align="right" class="new-manage-org-action-head">
				<a class="new-manage-org-link" 
				   href="handleNews.htm?cmd=add"> + <spring:message  code="add.news"/></a>
				   &nbsp;|&nbsp;
				<a class="new-manage-org-link" onClick="deleteNews()"
				   href="javascript:void(0);"><spring:message  code="delete.news"/></a>   
			</div>
		</c:if>
		
		<c:forEach var="news" items="${bean.news}">
		
			<div class="new-manage-org-folder-news">
				<c:if test="${bean.isAdmin == true}">
					<div class="new-manage-org-checkOrg">										
					   <form:checkbox path="newsIds" value="${news.newsid}" cssClass="ckbChild"/>										
					</div>
				</c:if>
				
				<c:set value="articleDetail.htm?id=${news.newsid}" var="detailUrl"></c:set> 
				<div class="new-manage-org-logo-org">		
				    <a href="${detailUrl}">		     				     
						<c:set value="${fn:trim(news.imageurl)}" var="imageurl" />
						<c:choose>
						<c:when test="${imageurl == null || imageurl == ''}">
							<div class="logo" align="center">
								<img onLoad="scaleImg(this,150,120)" alt="" src="/pim/images/small_noImage.gif"/>
							</div>
						</c:when>
						<c:otherwise>
							<div class="logo" align="center">
								 <img alt="" src="${imageurl}" onLoad="scaleImg(this,150,120)"/>
							</div>
						</c:otherwise>
						</c:choose>
					</a> 					  
				 </div>
				 
				 <div class="new-manage-org-content">					
					<span class="new-manage-org-name"> 
					  <c:if test="${bean.isAdmin}">
						  <span class="v-bt-edit">
							  <a href="handleNews.htm?id=${news.newsid}&cmd=edit" 
							      class="v-link" ><spring:message code="button.edit" />
							   </a>
						  </span>
						  &nbsp;
		              </c:if>
		              <a class="new-manage-org-link" href="${detailUrl}">					
					    <c:out value="${news.title}"></c:out>		
					  </a>		   
					</span>										
				 </div>
				 
				 <p>		             
				    <span class="author">${news.createdBy}, <fmt:formatDate pattern="yyyy-MM-dd  hh:ss" value="${news.updatedAt}" /></span>  
		         </p>
																		
				<div style="padding-left: 5px; float: left; width: 460px;text-align: justify;">
					<span class="pg-normal-content">
					  <c:choose>
						<c:when test="${fn:length(news.description) > 200}">
							<c:out value="${fn:substring(news.description, 0, 200)}..." escapeXml="false" />
						</c:when>
						
						<c:otherwise>
							<c:out value="${news.description}" escapeXml="false"></c:out>
						</c:otherwise>
					  </c:choose>					 
					</span>
				</div>
				<div style="width: 460px; float: left;">
				 	<a href="${detailUrl}" style="text-decoration: none">
						<span class="tg-content-blue" style="float: right;"><spring:message  code="see.more"/></span>
					</a>
				</div>				
			</div>
			<br />
		</c:forEach>		
		</c:otherwise>		
		</c:choose>
	</div>
 
    <c:if test="${bean.total > bean.itemsPerPage}">
    <div id="paging" class="productView-paging" style="width: 680px;float:right;padding-bottom:20px;">		
			<c:set value="${bean.paging}" var="paging"></c:set>
			<%@ include file="include/common/pagination.jsp"%>		
    </div>
    </c:if>

    <input type="hidden" name="cmd"/>
</form:form>
</div>	
</div>
</div>
<div class="footer">
	<jsp:include page="include/common/footer.jsp" />
</div>
</div>
</c:if>
<% } catch(RuntimeException re){ re.printStackTrace(); } %>
</body>
</html>